package com.kaifamiao.thread.d0926;

import java.util.concurrent.*;

public class Demo02 {

    public static void main(String[] args) throws ExecutionException, InterruptedException, TimeoutException {
        Callable<Integer> callable = new MyCallable();

        FutureTask<Integer> futureTask = new FutureTask<>(callable);

        Thread t = new Thread(futureTask, "callable 线程");

        t.start();

        int result = futureTask.get(2, TimeUnit.SECONDS);
        System.out.println(result);

        System.out.println(Thread.currentThread());

        System.out.println("end");
    }
}
